<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="description" content="" />
        <meta name="keywords" content="" />
        <meta name="author" content="Flying hormone" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta charset="UTF-8">
        <link rel="stylesheet" href="../css/media.css" />
        <link rel="stylesheet" href="../css/mui.min.css" />
        <link rel="stylesheet" href="../css/head_foot.css" />
        <script type="text/javascript" src="../js/jquery-1.9.1.js"></script>
        <script type="text/javascript" src="../js/jquery.Query.js" ></script>
        <script type="text/javascript" src="../js/jquery-cookie.js"></script>
        <script type="text/javascript" src="../js/mui.min.js"></script>
        <script type="text/javascript" src="../js/appcan.js"></script>
        <script type="text/javascript" src="../js/appcan.control.js"></script>
        <script type="text/javascript" src="../js/common.js" ></script>
        <title>商品上架</title>
        <style>
            
            .shucailei {
                margin-top: 0.625em;
                height: auto;
                overflow: hidden;
                background: #fff;
            }
            
            .shucailei h2 {
                background: #fff;
                color: #666;
                padding: 0.625em;
                font-size: 0.875em;
                line-height: 1.5em;
                position: relative;
            }
            
            .shucailei h2 span {
                float: left;
                margin-top: 0.3em;
                font-size: 1em;
            }
            
            .shucailei h2 a {
                position: absolute;
                z-index: 100;
                right: 1em;
                color: #666;
                border: 1px solid #ff3366;
                padding: 0 0.625em;
                border-radius: 0.3125em;
            }
            
            input[type=text]{
                line-height: 2.5em;
                height: 2.5em;
                margin-bottom: 0;
                font-size: 1em;
                width: 60%;
            }
            
            .shucailei>p {
                background: #f9efc9;
                text-align: center;
                position: relative;
                line-height: 1.875em;
            }
            
            .shucailei>p a {
                position: absolute;
                right: 0.3125em;
                color: #ff5256;
            }
            
            .shucailei i {
                font-style: normal;
                color: #ff3366;
                margin-right: 0.625em;
            }
            
            .shucailei .mui-table-view .mui-media-object {
                max-width: 30%;
                height: auto;
            }
            
            .shucailei .mui-table-view-cell>a:not(.mui-btn) {
                white-space: normal;
            }
            
            .shucailei .mui-ellipsis {
                white-space: normal;
            }
            
            .shucailei .search {
                background: #87d4fe;
                border: none;
                height: 2em;
                position: absolute;
                width: 60%;
                padding: 0;
                margin: 0 auto;
                margin-top: 0.3125em;
                display: block;
                top: 0;
                left: 20%;
            }
            
            .shucailei .search input[type=text] {
                background: none;
                border: none;
                text-indent: 0.625em;
                padding: 0;
                margin: 0;
                height: 1.5em;
                font-size: 0.75em;
                width: 100%;
                height: 100%;
            }
            
            .shucailei .search img {
                height: 60%;
                position: absolute;
                top: 0.3125em;
                right: 0.3125em;
            }
            .shucailei li{
                padding: 0.625em;
            }
            .shucailei li p{
                font-size: 0.8em;
            }
            .shucailei>span{
                display: inline-block;
                width: 46%;
                float: left;
                text-align: center;
                color: #ff3366;
                background: #fff;
                border: 1px solid #ff3366;
                padding: 0 5%;
                margin: 0 2%;
                line-height: 1.5em;
            }
            .shucailei>span a{
                color: #ff3366;
            }
            .shucailei>span:last-child{
                background: #ff3366;
                color: #fff;
            }
            .shucailei>span:last-child a{
                color: #fff;
            }
            .del_bianji{
                position: absolute;
                top: 0.625em;
                right: 0;
                font-size: 0.875em;
            }
            .del_bianji a{
                color: #999;
                padding: 0.125em 0.375em;
                margin-right: 0.3125em;
                border: 1px solid #ccc;
            }
            .buff{
                height: 1.875em;
            }
            .buff a{
                width: 50%;
                display: block;
                float: left;
                color: #999;
                background: #fff;
                line-height: 1.875em;
                text-align: center;
                border-right: 1px solid #eee;
                line-height: 2.375em;
            }
            .buff a.active{ color: #ff3366;}
            
            .mui-table-view-cell>a:not(.mui-btn){
                padding: 0;
            }
        </style>
    </head>

    <body>
        <header>
            <a><span class="leftleft"></span></a>
            <h1>商品编辑</h1>
        </header>
        <section class="buff">
            <a class="shangjia">正在发布</a>
            <a class="active">已下架</a>
        </section>
        
        <section class="shucailei" id="addView">
            <div>
                <ul class="mui-table-view">
                    <li class="mui-table-view-cell mui-media">
                        
                    </li>
                </ul>
            </div>
        </section>
        <footer>
            <nav class="mui-bar mui-bar-tab">
                <a href="javascript:;" id="tcIndex">
                    <img src="../img/shouye2.png" />
                    <span class="mui-tab-label">首页</span>
                </a>
                <a class="action" href="javascript:;" id="myfabu">
                    <img src="../img/fabu2b.png" />
                    <span class="mui-tab-label">发布</span>
                </a>
                <a href="javascript:;" id="myInfo">
                    <img src="../img/mine.png" />
                    <span class="mui-tab-label">我的</span>
                </a>
            </nav>
        </footer>
        <script>
        //获取已添加的商品
        var type = getVal("type");
        var actId = getVal("actId");
        
        $(function(){
            // 获取默认名片
            appcan.ajax({
               type:"get",
               url:host+"/getActItem.json?actId="+actId,
               dataType:"json",
               success : function(dataResult) {
                   var data = dataResult.data;
                   var str = '';
                   for (var i=0; i < data.length; i++) {
                     var befStr = '<section class="shucailei"><h2><span class="kaihe mui-icon mui-icon-arrowdown"></span>'
                     +data[i].cateName+'</h2>'
                     +'<div><ul class="mui-table-view">';
                     var itemList = data[i].itemList;
                     var itemStr = '';
                     for (var j=0; j < itemList.length; j++) {
                        var yourtime=itemList[j].endTime+" 23:59:59";
                        yourtime = yourtime.replace("-","/");//替换字符，变成标准格式
                        var d2=new Date();//取今天的日期
                        var d1 = new Date(Date.parse(yourtime));
                        // 未结束 未下架的
                       if(d1<d2 || itemList[j].updateBy == "1"){
                           itemStr+='<li class="mui-table-view-cell mui-media"><div><img class="mui-media-object mui-pull-left" src="'
                           + hostIp+itemList[j].itemPic +'"><div class="mui-media-body">品名：'
                           +itemList[j].itemName +'<p><i>特价：'
                           +itemList[j].spePrice +'元/'
                           +itemList[j].speUnit+'</i>原价：<s>'
                           +itemList[j].listPrice+'元/'
                           +itemList[j].listUnit+'</s></p><p>时间：'
                           +itemList[j].startTime+' 至 '
                           +itemList[j].endTime+'</p><p class="mui-ellipsis">说明：'
                           +itemList[j].remark+'</p></div><p class="del_bianji"><a onclick="delGood(\''+itemList[j].id+'\');">上架</a><a onclick="getGood(\''+itemList[j].id+'\',\''+data[i].cateId+'\');">编辑</a></p></div></li>';
                       }
                     };
                     if(itemStr.length != 0){
                         str+= befStr + itemStr + '</ul></div></section>';
                     }
                   };
                   
                   $("#addView").before(str);
                   $(".kaihe").click(function(){
                        if($(this).is(".mui-icon-arrowdown")){
                            $(this).removeClass("mui-icon-arrowdown");
                            $(this).addClass("mui-icon-arrowup");
                            $(this).parent("h2").next("div").hide();
                        }else{
                            $(this).removeClass("mui-icon-arrowup");
                            $(this).addClass("mui-icon-arrowdown");
                            $(this).parent("h2").next("div").show();
                        }
                    });
                    
               }
           });
           
           $(".shangjia").click(function(){
                openUrl("good_edit.html?actId="+actId,"good_edit");
            });
            
        });
        function getGood(actItemId,cateId){
            // 获取商品信息
           openUrl("add_good.html?itemId="+actItemId+"&type="+type+"&actId="+actId+"&cateId="+cateId,"add_good");
        }
        
        function delGood(actItemId){
            // 删除商品
            if(confirm('你确定要上架?')){
                appcan.ajax({
                   type:"post",
                   url:host+"/upItem.json?itemId="+actItemId,
                   dataType:"json",
                   success : function(dataResult) {
                       openUrl("good_xiajia.html?actId="+actId,"good_xiajia");
                   }
               });
           }
        }
        </script>
    </body>

</html>